package com.ruoyi.common.utils;

import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;

public class DateUtil extends DateUtils {

    public static void main(String[] args) throws ParseException {

        DateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        Date date = df.parse("2021-10-29 00:00:00");
        Calendar cal = Calendar.getInstance();
        cal.setTime(date);
        long tim = cal .getTimeInMillis();
        System.out.println(tim);

        System.out.println(System.currentTimeMillis());
    }


    /**
     * @author jiangguanjun
     * @date 2023/2/9 14:41
     * @param
     * @return
     * @desc 获取之后多少天
     */
    public static Date getBeforTime(int value,int timeUnit){
        Calendar calendar = Calendar.getInstance() ;
        calendar.add(timeUnit,value);
        Date expDate = calendar.getTime();
        return expDate ;
    }

    /**
     * @author jiangguanjun
     * @date 2023/2/9 14:41
     * @param
     * @return
     * @desc 获取当前时间之后多少
     */
    public static Date getBeforTime(Date date,int value,int timeUnit){
        Calendar calendar = Calendar.getInstance() ;
        calendar.setTime(date);
        calendar.add(timeUnit,value);
        Date expDate = calendar.getTime();
        return expDate ;
    }


}
